/*
 * @lc app=leetcode.cn id=242 lang=c
 *
 * [242] 有效的字母异位词
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

// @lc code=start
char *isAnagram(char *s, char *t)
{
    printf(">>> s:%s, len:%d\n", s, strlen(s));
    printf(">>> t:%s, len:%d\n", t, strlen(t));
    int map_data[128] = {0};
    int i;
    if (strlen(s) != strlen(t))
    {
        return "false";
    }
    int len = strlen(s);
    for (i = 0; i < len; i++)
    {
        printf("1 %d s:%d %c\n", i, *s, *s);
        map_data[*s] = map_data[*s] + 1;
        printf("map_data1[%c]:%d\n", *s, map_data[*s]);
        s++;
    }

    for (i = 0; i < len; i++)
    {
        printf("2 %d s:%d %c\n", i, *t, *t);
        if (map_data[*t] == 0)
        {
            return "false";
        }
        map_data[*t] = map_data[*t] - 1;
        printf("map_data2[%c]:%d\n", *t, map_data[*t]);
        t++;
    }
    return "true";
}

int main(int argc, char **argv)
{
    printf(">>> a:%d, z:%d\n", 'a', 'z');
    char *res = isAnagram("abcddd", "cdabdd");
    printf(">>>> res:%s\n", res);

    int *cur = malloc(sizeof(int) * 1);
    *cur = 0;
    (*cur)++;
    printf("cur:%d\n", *cur);
    // printf("INT_MAX:%d\n", INT_MAX);
    return 0;
}

// @lc code=end
